Skip to content

Run CommandTestBase teardown via IAsyncLifetime on xUnit v2 - #9872

Merged
glen-84 merged 2 commits into
mainfrom
gai/commandtestbase-iasynclifetime
Jun 8, 2026
Merged

glen-84 merged 2 commits into
mainfrom
gai/commandtestbase-iasynclifetime

Conversation

@glen-84

@glen-84 glen-84 commented Jun 8, 2026

Copy link
Copy Markdown
Member

Summary

  • CommandTestBase (the base for all Nitro CLI command tests) implemented IAsyncDisposable, which xUnit v2 does not invoke on test classes — so the Moq VerifyAll() in its DisposeAsync teardown never ran, silently skipping mock verification for the whole suite.
  • Switch it to IAsyncLifetime so xUnit v2 runs the teardown.

This surfaces pre-existing failures in FusionPublishCommandTests (16) and FusionValidateCommandTests (5): their Strict-mock setups (DownloadLatestFusionArchiveAsync / ReleaseDeploymentSlotAsync) are never matched by the command, which VerifyAll was supposed to catch but never did. Those expectations need correcting (the command doesn't make those calls in those scenarios, or the setups are over-specified).

Test plan

  • Built ChilliCream.Nitro.CommandLine.Tests; the teardown now executes under xUnit v2.
  • Confirmed the Fusion command tests now run VerifyAll, surfacing the 21 mock-expectation mismatches that were previously skipped.

Copilot AI review requested due to automatic review settings June 8, 2026 13:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Nitro CLI command test base class teardown to run under xUnit v2 by switching from IAsyncDisposable (not invoked by xUnit v2 on test classes) to IAsyncLifetime, ensuring Moq strict-mock verification (VerifyAll) actually executes after each test.

Changes:

  • Replace IAsyncDisposable with IAsyncLifetime on CommandTestBase so xUnit v2 invokes async teardown.
  • Add InitializeAsync() (no-op) and update DisposeAsync() to the Task-returning xUnit shape.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

VerifyAll() in CommandTestBase teardown now runs via IAsyncLifetime,
surfacing Fusion publish/validate tests that configured mock setups
their scenario never invokes (legacy archive download when a local
--legacy-v1-archive is supplied, and release-slot mutation on paths
that never throw). Removed the unused setups so VerifyAll passes.
@glen-84
glen-84 merged commit bb3cdf2 into main Jun 8, 2026
141 of 142 checks passed
@glen-84
glen-84 deleted the gai/commandtestbase-iasynclifetime branch June 8, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants